.\" Copyright (c) 1988, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     %A%
.\"
.Dd November 21, 2004
.Dt POSTOFFICE 8
.Os MASTODON 4
.Sh NAME
.Nm postoffice
.Nd internet mail server
.Sh SYNOPSIS
.Nm
.Op Ar flags
.Op Ar address ...
.Sh DESCRIPTION
.Nm
accepts and delivers mail on
.Em TCP/IP
networks. It includes a mail
.Em greylist ,
uses 
.Sy "TCP wrappers"
to restrict client access,
and can be configured to run antivirus
.\" and antispam
software before accepting mail for delivery.
.Pp
With no flags,
.Nm
reads its standard input
up to an end-of-file
and sends a copy of the message found there
to all of the addresses listed on the command line.
.Pp
Local addresses are looked up in a file
and aliased appropriately.
.Pp
Flags are:
.Bl -tag -width Fl
.It Fl a
Start SMTP servers with session auditing enabled.
If session logging is enabled, 
.Nm
will log all sorts of information about each
SMTP session to the syslog.  See
.Xr mailaudit 5
for details about the format of the audit records.
.It Fl bd
Run as a daemon.
.Nm
will fork and run in background
listening on socket 25 for incoming SMTP
connections.
.It Fl bD
Run as a service.
.Nm
will run in the foreground
listening on socket 25 for incoming SMTP connections.
.It Fl bi
Initialize the alias database.
@VHOST@If a 
@VHOST@.Ar host
@VHOST@is passed on the command line, 
@VHOST@.Nm Postoffice
@VHOST@will rebuild the aliases file for that virtual host, otherwise
@VHOST@it will rebuild the system alias file
@VHOST@.Ar /etc/aliases .
.It Fl bm
Deliver mail in the usual way (default).
.It Fl bp
Print a listing of the queue.
.It Fl bq
Process messages in the queue.
.It Fl bs
Use the SMTP
protocol as described in
.Em RFC821
on standard input and output.
.It Fl C Ns Ar file
Read options from the named configuration file instead of from
.Pa @confdir@/postoffice.cf .
.It Fl d
When running as a daemon, 
.Nm
will not fork and run in the background, but will instead stay
attached to the controlling terminal.
.\" .It Fl d Ns Ar X
.\" Set debugging value to
.\" .Ar X .
.It Fl f Ns Ar name
Sets the name of the
.Ql from
person
(i.e., the sender of the mail).
.Fl f
can only be used
by 
.Em root
or if the person you are trying to become
is the same as the person you are.
.It Fl o Ns Ar x Ns = Ns value
Set option
.Ar x
to the specified
.Em value .
Options are described in the
.Xr postoffice.cf 5
manpage.
.It Fl q
An alternate form of the
.Fl bq
flag.
.It Fl q Ns Ar X
Start a daemon to process the mail queue
every
.Ar X
minutes.
.\" .It Fl M Ns Ar ident
.\" Process the queued message with the queue id
.\" .Ar ident .
.\" .It Fl R Ns Ar addr
.\" Process the queued messages that have the string
.\" .Ar addr
.\" in one of the recipient addresses.
.\" .It Fl S Ns Ar addr
.\" Process the queued messages that have the string
.\" .Ar addr
.\" in the sender address.
.It Fl r Ns Ar name
An alternate form of the
.Fl f
flag.
.It Fl v
Go into verbose mode.
.It Fl V
Report version information for this copy of
postoffice, then exit successfully.
.El
.Pp
Various processing options can be set when 
.Nm
is started.
Options may be set either on the command line
using the
.Fl o
flag,
in the configuration file
.Pa @confdir@/postoffice.cf ,
or in a configuration file specified by the
.Fl C
flag.
.Pp
In aliases,
the first character of a name may be
a vertical bar to cause interpretation of
the rest of the name as a command
to pipe the mail to.
It may be necessary to quote the name
to keep
.Nm
from suppressing the blanks from between arguments.
For example, a common alias is:
.Pp
.Bd -literal -offset indent -compact
msgs: "|/usr/bin/msgs -s"
.Ed
.Pp
.Nm
returns an exit status
describing what it did.
The codes are defined in
.Aq Pa sysexits.h :
.Bl -tag -width EX_UNAVAILABLE -compact -offset indent
.It Dv EX_OK
Successful completion on all addresses.
.It Dv EX_NOUSER
User name not recognized.
.It Dv EX_UNAVAILABLE
Catchall meaning necessary resources
were not available.
.It Dv EX_SYNTAX
Syntax error in address.
.It Dv EX_SOFTWARE
Internal software error,
including bad arguments.
.It Dv EX_OSERR
Temporary operating system error,
such as
.Dq cannot fork .
.It Dv EX_OSFILE
.Pa @confdir@/postoffice.cf
or 
.Pa @confdir@
is world writable or is not owned by
.Ar root .
.It Dv EX_NOPERM
You do not have sufficient permissions.
.It Dv EX_IOERR
.Nm
was unable to create or write a file.
.El
.Pp
If invoked as
.Sy newaliases ,
.Nm
will rebuild the alias database.
If invoked as
.Sy mailq ,
.Nm
will print the contents of the mail queue.
If invoked as
.Sy runq ,
.Nm
will run through the mail queue and make what deliveries are possible.
If invoked as
.Sy smtpd ,
.Nm
runs as a SMTP daemon.
.Sh FILES
.Pp
.Bl -tag -width /var/db/smtpauth.db -compact
.It Pa @confdir@/postoffice.cf
Default
.Nm
options.
.It Pa /etc/aliases
raw data for alias names.
.It Pa /etc/aliases.db
data base of alias names.
.It Pa /etc/issue.smtp
smtp server welcome banner.
.It Pa /var/spool/mqueue/*
temp files.
.It Pa /var/db/smtpauth.db
.Sy greylist
database.
.El
.Sh SEE ALSO
.Xr mail 1 ,
.Xr rmail 1 ,
.Xr syslog 3 ,
.Xr aliases 5 ,
@VHOST@.Xr domains.cf 5 ,
.Xr mailaudit 5 ,
.Xr postoffice.cf 5 ,
.Xr smtpauth 5 ,
.Xr usermap 7 ,
@VHOST@.Xr vhosts 7 ,
.Xr mailaddr 7 ,
.Xr authexpire 8 ,
.Xr sendmail 8 ,
.Xr smtpd 8 ;
.Pp
DARPA
Internet Request For Comments
.%T RFC819 ,
.%T RFC821 ,
.%T RFC822 .
